<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
        <style type="text/css">
            <!--
            .style1 {
                color: #20364E;
                font-size: 24px;
                font-weight: bold;
            }
            .style9 {
                font-size: 36px
            }
            body {
                background-color: #A7BFDB;
            }
            -->
        </style>
</head>

<body>
        <p align="center"><span class="style1">Cadastro de Categoria</span></p>
        <%
                    Class.forName("org.postgresql.Driver");
                    Connection con = DriverManager.getConnection("jdbc:postgresql://localhost/ses", "postgres", "postgres");
                    Statement st = con.createStatement();
                    ResultSet rs;

                    if (request.getParameter("acao") == null) {

        %>
        <label></label>
        <label></label>
        <label></label>
<form id="frmInserirCategoria" name="frmInserirCategoria" method="post" action="cadCategoria.jsp?acao=gravar">
  <table width="627" border="0" align="center">
    <tr>
      <td colspan="4"><p>&nbsp;</p>                        </td>
    </tr>
    <tr>
      <td width="55">C&oacute;digo.:</td>
      <td width="123"><input name="tf_codigo" type="text" id="tf_codigo" value="autom&aacute;tico" size="19" maxlength="15" disabled="disabled"/></td>
      <td width="147">Nome Categoria.:</td>
      <td width="243"><input name="tf_categoria" type="text" id="tf_categoria" size="25" maxlength="25" />
      <label></label></td>
    </tr>
    <tr>
      <td><label>Natureza.:</label></td>
      <td colspan="3"><select name="lista_natureza" id="lista_natureza">
      	<option></option>
        <option value="Cr&eacute;dito">Cr&eacute;dito</option>
        <option value="D&eacute;bito">D&eacute;bito</option>
                                    </select></td>
    </tr>
    <tr>
                        <td colspan="4">&nbsp;</td>
    </tr>
    <tr>
      <td colspan="4"><input type="submit" name="gravar" id="gravar" value="Gravar" />
      <input type="reset" name="Limpar" id="Limpar" value="Limpar" /></td>
    </tr>
  </table>
  <div align="center"></div>
                    <label></label>
  <p>
                <label></label>
        <label></label>
  </p>
</form>
        <% } else {
                        String sqlinsertcat = "insert into categoria (nome, natureza) " +
                                " VALUES ('" + request.getParameter("tf_categoria") +
                                "','" + request.getParameter("lista_natureza") + "')";

                        st.executeUpdate(sqlinsertcat);
                        response.sendRedirect("cadCategoria.jsp");
                    }%>
        <p align="center" class="style9">&nbsp;</p>
        <p>&nbsp;</p>
</body>
</html>